﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Krile.Forms.MainForm.Controls.XTab
{
    public class XTabDroppable
    {
        public bool DroppableNew
        {
            get { return OnDropToNew != null; }
        }

        public bool DroppableAppend
        {
            get { return OnDropToAppend != null; }
        }

        public Action<XTab> OnDropToNew;

        public Func<XTab, bool> OnDroppableThis;

        public bool DroppableThis(XTab target)
        {
            if (OnDroppableThis != null)
                return OnDroppableThis.Invoke(target);
            else
                return true;
        }

        public void DropToNew(XTab parent)
        {
            if (OnDropToNew != null)
                OnDropToNew.Invoke(parent);
            else
                throw new InvalidOperationException("event handler is not supported.");
        }

        public Action<XTab, XTabItem> OnDropToAppend;

        public void DropToAppend(XTab parent, XTabItem append)
        {
            if (OnDropToAppend != null)
                OnDropToAppend.Invoke(parent, append);
            else
                throw new InvalidOperationException("event handler is not setted.");
        }
    }
}
